//
//  TwoViewController.m
//  heheda
//
//  Created by admid on 16-5-26.
//  Copyright (c) 2016年 wyr_oc. All rights reserved.
//
#import "TwoViewController.h"

@interface TwoViewController ()

@end

@implementation TwoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"呵呵哒";//标题编辑
    self.view.backgroundColor = [UIColor yellowColor];
    
    
    
    
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"二叶";
    self.view.backgroundColor = [UIColor whiteColor];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
    [btn setTitle:@"按键" forState:UIControlStateNormal];
    [btn setTitle:@"按了" forState:UIControlStateHighlighted                                                                                                                                                                                                                                                                                                       ];
    
    [btn setImage:[UIImage imageNamed:@"5"] forState:UIControlStateNormal];
    btn.layer.borderWidth = 1;
    btn.layer.cornerRadius = 6;
    //按键边框颜色
    btn.layer.borderColor = [UIColor redColor].CGColor;
    //按键大小
    btn.frame = CGRectMake(0, 0, 100, 44);
    
    btn.center = CGPointMake(self.view.frame.size.width/2,100);
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    [btn addTarget:self action:@selector(onClick2:) forControlEvents:UIControlEventTouchDown];
    
    
    //按键显示屏幕上
    [self.view addSubview:btn];
    
    UILabel *l = [[UILabel alloc] initWithFrame:CGRectMake(16, 150, 100, 44)];
    l.text = @"UILabel看一下";
   // UISwitch
   // UISlider
   // UIProgressView
   // UIActivityIndicatorView
   // UISegmentedControl
    [self.view addSubview:l];
    UISwitch *swi = [[UISwitch alloc] init];
    [swi sizeToFit];
    swi.center = CGPointMake(150, 150);
    [self.view addSubview:swi];
    [swi addTarget:self action:@selector(onSwitch:) forControlEvents:UIControlEventEditingChanged];
    
    
    
    
    
}
-(void)onSwitch:(UISwitch *)swi
{
    UILabel *l = (UILabel *)[self.view viewWithTag:100];
    if (swi.isOn) {
        l.layer.borderWidth = 1;
    }else{
        l.layer.borderWidth = 0;
    
    }
    
}





-(void) onClick:(UIButton *)sender
{
    sender.backgroundColor = [UIColor whiteColor];
}

-(void) onClick2:(UIButton *)sender
{

    sender.backgroundColor = [UIColor blueColor];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
